package net.zjitc.seqqueue.myservice;

import net.zjitc.exception.MyQuException;
import net.zjitc.seqqueue.IQueue;

/**
 * Created by Administrator on 2017/4/6.
 */
public class WindowService extends Thread {

    private IQueue<Integer> queue;/*由机器产生的队列*/
    public WindowService(IQueue<Integer> queue) {
        this.queue=queue;
    }

    @Override
    public void run() {
    //取数字
            while (true){
                synchronized (queue){
                try {
                    Integer callNum=queue.dequeue();
                    System.out.println("请"+callNum+"号到"+Thread.currentThread().getName()+"窗口处理业务");
                } catch (MyQuException e) {
                    /*System.out.println(e.getMessage());*/
                }
                }
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    System.out.println(e.getMessage());
                }
            }


    }
}
